package com.ruoyi.system.api.wrapper;

import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteSysUserService;
import com.ruoyi.system.api.domain.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 用户信息微服务包装服务，对微服务接口进行了封装，直接返回需要的数据。
 *
 * @author ruoyi
 * @date 2023-04-27
 */
@Component
public class RemoteSysUserWrapperService extends RemoteBaseWrapperService {

    @Autowired
    private RemoteSysUserService remoteSysUserService;

    /**
     * 查询用户信息
     *
     * @param userId 用户信息主键
     * @return 用户信息
     */
    public SysUser selectSysUserByUserId(Long userId) {
        R<SysUser> result = remoteSysUserService.selectSysUserByUserId(userId, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 查询用户信息列表
     *
     * @param sysUser 用户信息
     * @return 用户信息集合
     */
    public List<SysUser> selectSysUserList(SysUser sysUser) {
        R<List<SysUser>> result = remoteSysUserService.selectSysUserList(sysUser, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 新增用户信息
     *
     * @param sysUser 用户信息
     * @return 结果
     */
    public Integer insertSysUser(SysUser sysUser) {
        R<Integer> result = remoteSysUserService.insertSysUser(sysUser, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 修改用户信息
     *
     * @param sysUser 用户信息
     * @return 结果
     */
    public Integer updateSysUser(SysUser sysUser) {
        R<Integer> result = remoteSysUserService.updateSysUser(sysUser, SecurityConstants.INNER);
        return processResult(result);
    }

    /**
     * 批量删除用户信息
     *
     * @param userIds 需要删除的用户信息主键集合
     * @return 结果
     */
    public Integer deleteSysUserByUserIds(Long[] userIds) {
        R<Integer> result = remoteSysUserService.deleteSysUserByUserIds(userIds, SecurityConstants.INNER);
        return processResult(result);
    }
}
